package com.lc.schedule.dao.impl;

import com.lc.schedule.dao.BaseDao;
import com.lc.schedule.dao.SysUserDao;
import com.lc.schedule.pojo.SysUser;

import java.util.List;

/**
 * @author liuchun
 */
public class SysUserDaoImpl extends BaseDao implements SysUserDao {
    @Override
    public int addSysUser(SysUser user) {
        String sql = "insert into sys_user values(default,?,?)";
        return  baseUpdate(sql,user.getUsername(),user.getUserPwd());
    }

    @Override
    public SysUser findByUserName(String username) {
       String sql = "select uid, username, user_pwd userPwd from sys_user where username = ?";
        List<SysUser> sysUserlist = baseQuery(SysUser.class, sql, username);
        //System.out.println(sysUserlist.get(0));
        return sysUserlist!=null && sysUserlist.size()>0 ? sysUserlist.get(0) : null ;
    }
}
